package com.example.eurekaconsumer.controller;

import com.example.eurekaconsumer.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Date: 2021/2/19 10:57
 * @Author: yulei
 * @Description:
 */
@RestController
@RequestMapping("/Index")
public class IndexController {

    @Autowired
    private SysUserService sysUserService;

    @GetMapping("/hello")
    public String hello() {
        System.out.println("服务提供者1。。。。。。。");
        return "Hello, Spring Cloud，Provider 1";
    }
    /**
     * 首页数据
     * @return
     */
    @RequestMapping("index")
    public List index() {
        List list = sysUserService.getGoods();
        return list;
    }

    /**
     * 首页精品推荐
     *
     * @param request
     * @param model
     * @return
     */
    @RequestMapping("/boutique")
    public String boutique(HttpServletRequest request, Model model) {
        List list = sysUserService.getList(request, "");
        model.addAttribute("keywords", (request.getParameter("keywords")) == null ? "" : request.getParameter("keywords"));
        model.addAttribute("title", "列表");
        model.addAttribute("goods", list);
        return "goods/pro_list";
    }

}
